<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // s1成功了去执行s2 
        // let s1 = new Promise((resolve,reject)=>{
        //     resolve('S1成功了！')
        // })
        // // s1.then(()=>{},()=>{})//than里面两个回调方法 对应resolve 和reject


        // let s2 = s1.then(res=>{
        //     return new Promise((resolve,reject)=>{
        //         console.log(res)
        //         resolve("S2也成功了！")
        //     })
        // },err=>{
        //         console.log(err)
        //     }
        // )
        // s2.then(
        //     res=>{
        //         console.log(res);
        //     },
        //     err=>{
        //         console.log(err)
        //     }
        // )
        
        //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓修改为链式调用↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
        let s1 = new Promise((resolve,reject)=>{
            resolve('S1成功了！')
        }).then(res=>{
            return new Promise((resolve,reject)=>{
                console.log(res)
                resolve("S2也成功了！")
            })
        },err=>{
                console.log(err)
            }
        ).then(
            res=>{
                console.log(res);
            },
            err=>{
                console.log(err)
            }
        )
    </script>
</body>
</html>